package com.example.springbootredis.service.impl;

import com.example.springbootredis.entity.Classroom;
import com.example.springbootredis.repository.ClassroomRepository;
import com.example.springbootredis.service.ClassroomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassroomServiceImpl implements ClassroomService {

    @Autowired
    private ClassroomRepository classroomRepository;

    @Override
    public Classroom save(Classroom classroom) {
        return classroomRepository.save(classroom);
    }

    @Override
    public List<Classroom> findAll() {
        return classroomRepository.findAll();
    }

    @Override
    public void deleteClassroomById(Long id) {
        classroomRepository.deleteById(id);
    }

    @Override
    public List<Classroom> findByCampus(String campus) {
        return classroomRepository.findByCampus(campus);
    }

    @Override
    public List<Classroom> findByClassroomNameContaining(String classroomName) {
        return classroomRepository.findByClassroomNameContaining(classroomName);
    }

    @Override
    public List<Classroom> findByCampusAndClassroomNameContaining(String campus, String classroomName) {
        return classroomRepository.findByCampusAndClassroomNameContaining(campus, classroomName);
    }

    @Override
    public boolean existsByClassroomNo(String classroomNo) {
        return classroomRepository.existsByClassroomNo(classroomNo);
    }

    @Override
    public boolean existsByClassroomNoAndIdNot(String classroomNo, Long id) {
        return classroomRepository.existsByClassroomNoAndIdNot(classroomNo, id);
    }
}